import fs from "fs";
interface Options {
  rootPath?: string;
  from?: string;
  to?: string;
  targets?: { [p: string]: string }[];
  lazy?: true;
  outerPath?: string;
  appId?: string;
  key?: string;
  requestWordsNumber?: number;
  requestInterval?: number;
  suffix?: string;
  [p: string]: any;
}
export const getOptions = () => {
  let options: Options = {};

  try {
    options = JSON.parse(fs.readFileSync("config.json", "utf-8"));
  } catch (error) {
    [...process.argv.slice(2)].forEach((str) => {
      const [key, val] = str.split("=");
      options[key] = val;
    });
  } finally {
    return options;
  }
};
